#include <iostream>
#include "UdpServer.hpp"
#include <memory>
#include "LockGuard.hpp"
#include "Log.hpp"
using namespace std;
// using namespace dict_ns;
void Usage(string proc)
{
    cout << "usage:\n\t" << proc << "local_port\n"
         << endl;
}
//./udpServer ip port
int main(int argc, char *argv[])
{
    if (argc != /*3*/ 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERROR);
    }
    EnableScreen(); // 开启日志
    // 定义route消息转发模块
    MessageRoute route;

    // 网络模块
    //  string ip = argv[1];           // ip地址
    uint16_t port = stoi(argv[/*2*/ 1]); // 端口号
    // 智能指针指向UdpServer对象
    unique_ptr<UdpServer> usvr = make_unique<UdpServer>(port /*, ip*/, bind(&MessageRoute::Route, &route, placeholders::_1, placeholders::_2, placeholders::_3));
    // 初始化
    usvr->InitServer();
    // 启动
    usvr->Start();
    return 0;
}
